/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-12-21
*/
package com.rzico.account.entity;

import com.alibaba.fastjson.JSON;
import com.rzico.account.model.BankInfoVo;
import com.rzico.annotation.IgnoreSwaggerParameter;
import com.rzico.basics.entity.Enterprise;
import lombok.Data;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * <pre>
 *   名厨档案数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "wx_enterprise_deposit")
public class EnterpriseDeposit{
    @Id
    @ApiModelProperty(value = "" )
    protected Long id;

    @ApiModelProperty(value = "创建日期" )
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期" )
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "当前余额" )
    protected java.math.BigDecimal balance;

    @ApiModelProperty(value = "收入金额" )
    protected java.math.BigDecimal credit;

    @ApiModelProperty(value = "支出金额" )
    protected java.math.BigDecimal debit;

    @ApiModelProperty(value = "摘要" )
    protected String memo;

    @ApiModelProperty(value = "账户名称" )
    protected String attach;

    @ApiModelProperty(value = "凭证号" )
    protected String tranSn;

    @ApiModelProperty(value = "操作员" )
    protected String operator;

    @ApiModelProperty(value = "类型 {0:收款,1.退款,2:提现}" )
    protected Integer type;

    @ApiModelProperty(value = "状态(0.待确认,1.已确认,2.已完成)" )
    protected Integer status;

    @JsonIgnore
    @ApiModelProperty(value = "是否删除" ,hidden = true )
    protected Boolean deleted;

    @ApiModelProperty(value = "付款单 id" )
    protected Long paymentId;

    @ApiModelProperty(value = "退款单 id" )
    protected Long refundsId;

    @ApiModelProperty(value = "订单ID" )
    protected Long orderId;

    @ApiModelProperty(value = "所属企业" )
    protected Long enterpriseId;


    /**
     *  会员
     */
    @JsonIgnore
    @IgnoreSwaggerParameter
    protected Enterprise enterprise;

    public BankInfoVo getBankInfoVo() {
       if (getAttach()!=null) {
           return JSON.parseObject(getAttach(),BankInfoVo.class);
       } else {
           return null;
       }
    }

    public void setBankInfoVo(BankInfoVo value) {
        setAttach(JSON.toJSONString(value));
    }

    public String getMchName() {
        Enterprise enterprise = getEnterprise();
        if (enterprise!=null) {
            return enterprise.getName();
        } else {
            return null;
        }
    }

    public String getMchLogo() {
        Enterprise enterprise = getEnterprise();
        if (enterprise!=null) {
            return enterprise.getLogo();
        } else {
            return null;
        }
    }


}
